home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 151-175 / scopedisk155 / zkick / coldreboot.asm < prev    next >
Assembly Source File  |  1995-03-19  |  2KB  |  68 lines

  1. ****************************************************************************
  2. *
  3. *   NAME
  4. *    ColdReboot - Official code to reset any Amiga (Version 2)
  5. *
  6. *   SYNOPSIS
  7. *    ColdReboot()
  8. *
  9. *    void ColdReboot(void);
  10. *
  11. *   FUNCTION
  12. *    Reboot the machine.  All external memory and peripherals will be
  13. *    RESET, and the machine will start its power up diagnostics.
  14. *
  15. *   NOTE
  16. *    Rebooting an Amiga in software is very tricky.    Differing memory
  17. *    configurations and processor cards require careful treatment.  This
  18. *    code represents the best available general purpose reset.
  19. *
  20. *    The MagicResetCode must be used exactly as specified here. The code
  21. *    _must_ be longword aligned.  Failure to duplicate the code EXACTLY
  22. *    may result in improper operation under certain system configurations.
  23. *
  24. *   RESULT
  25. *    This function never returns.
  26. *
  27. ****************************************************************************
  28.  
  29.         SECTION code
  30.  
  31.         INCLUDE "exec/types.i"
  32.         INCLUDE "exec/libraries.i"
  33.  
  34.         XDEF    _ColdReboot
  35.         XREF    _LVOSupervisor
  36.  
  37. ABSEXECBASE        EQU 4        ;Pointer to the Exec library base
  38. MAGIC_ROMEND        EQU $01000000   ;End of Kickstart ROM
  39. MAGIC_SIZEOFFSET    EQU -$14        ;Offset from end of ROM to Kickstart size
  40. V36_EXEC        EQU 36        ;Exec with the ColdReboot() function
  41. TEMP_ColdReboot     EQU -726        ;Offset of the V36 ColdReboot function
  42.  
  43.  
  44. _ColdReboot:    move.l    ABSEXECBASE,a6
  45.         cmp.w    #V36_EXEC,LIB_VERSION(a6)
  46.         blt.s    old_exec
  47.         jmp    TEMP_ColdReboot(a6)     ;Let Exec do it...
  48.         ;NOTE: Control flow never returns to here
  49.  
  50.  
  51. ;---- manually reset the Amiga ---------------------------------------------
  52. old_exec:    lea.l    GoAway(pc),a5           ;address of code to execute
  53.         jsr    _LVOSupervisor(a6)      ;trap to code at (a5)...
  54.         ;NOTE: Control flow never returns to here
  55.  
  56.  
  57. ;-------------- MagicResetCode ---------DO NOT CHANGE-----------------------
  58.         CNOP    0,4            ;IMPORTANT! Longword align!
  59. GoAway:     lea.l    MAGIC_ROMEND,a0     ;(end of ROM)
  60.         sub.l    MAGIC_SIZEOFFSET(a0),a0 ;(end of ROM)-(ROM size)=PC
  61.         move.l    4(a0),a0                ;Get Initial Program Counter
  62.         subq.l    #2,a0            ;now points to second RESET
  63.         reset                ;first RESET instruction
  64.         jmp    (a0)                    ;CPU Prefetch executes this
  65.         ;NOTE: the RESET and JMP instructions must share a longword!
  66. ;---------------------------------------DO NOT CHANGE-----------------------
  67.         END
  68.